package com.mit.service.core.dao.impl;

import java.util.Date;
import java.util.HashMap;

import com.mit.service.core.dao.AbstractDAO;
import com.mit.service.core.dao.ITimestampDAO;

public class TimestampDAOImpl extends AbstractDAO implements ITimestampDAO {

	@Override
	public Date retrieveTimestamp(Integer id, String tableName) {
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("tableName", tableName);
		param.put("id", id);
		
		return (Date) getSqlMapClientTemplate().queryForObject("retrieveTimestamp", param);
	}

	@Override
	public void setCreationTime(Date timestamp, Integer id, String tableName) {
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("tableName", tableName);
		param.put("id", id);
		param.put("time", timestamp);
		getSqlMapClientTemplate().update("updateCreationTime", param);
	}

	@Override
	public void setLastUpdateTime(Date timestamp, Integer id, String tableName) {
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("tableName", tableName);
		param.put("id", id);
		param.put("time", timestamp);
		getSqlMapClientTemplate().update("updateLastUpdateTime", param);
		
	}

}
